import Helloworld from "./Helloworld";

// Learn TypeScript:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class item extends cc.Component {


    @property(cc.Sprite)
    sprite: cc.Sprite = null;

    ismine = false;

    indexX = 0;
    indexY = 0;
    index =0;
    @property(Helloworld)
    hello: Helloworld = null;

    isvisited = false;
    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}
    @property(item)
    thisItem: item = null;
    onLoad () {
        // console.log(this.sf);

    }

    onClick(){
        // this.sprite.spriteFrame = this.hello.sf[1];
        this.hello.onclick(this.thisItem);
    }
    
    setCount(count){
        this.sprite.spriteFrame = this.hello.sf[count + 1];
    }

    showMine(){
        // console.log(this.ismine);
        if(this.ismine){
            // console.log(this.sf[8])
            this.sprite.spriteFrame = this.hello.sf[8];
        }
    }

    reset(){
        this.sprite.spriteFrame = this.hello.sf[0];
        this.isvisited = false;
        this.indexX = 0;
        this.indexY = 0;
        this.index = 0;
        this.ismine = false;
    }

    boom(){
        this.sprite.spriteFrame = this.hello.sf[10];
    }
    // update (dt) {}
}
